package com.jdragon.common.proxy;

import javax.tools.SimpleJavaFileObject;
import java.net.URI;

/**
 * @Author: Jdragon
 * @email: 1061917196@qq.com
 * @Date: 2020.12.16 15:18
 * @Description:
 */

public class MemoryJavaFileObject extends SimpleJavaFileObject {

    private final CharSequence content;

    protected MemoryJavaFileObject(String className, CharSequence content) {
        super(URI.create("string:///" + className.replace('.', '/') + Kind.SOURCE.extension), Kind.SOURCE);
        this.content = content;
    }

    @Override
    public CharSequence getCharContent(boolean ignoreEncodingErrors) {
        return content;
    }

}